﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Input;
using StyleMVVM.ViewModel;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Documents;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using StyleMVVM.DependencyInjection;

// The Templated Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234235

namespace StyleMVVM.View
{
	public class CharmControl : ContentControl
	{
		public CharmControl()
		{
			this.DefaultStyleKey = typeof(CharmControl);

			BackCommand = new DelegateCommand(x => Bootstrapper.Instance.Container.Locate<ICharmService>().Back());
		}

		public Brush HeaderBackground
		{
			get { return (Brush)GetValue(HeaderBackgroundProperty); }
			set { SetValue(HeaderBackgroundProperty, value); }
		}

		// Using a DependencyProperty as the backing store for HeaderBackground.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty HeaderBackgroundProperty =
			DependencyProperty.Register("HeaderBackground",
			                            typeof(Brush),
			                            typeof(CharmControl),
			                            new PropertyMetadata(null));

		public Brush HeaderForeground
		{
			get { return (Brush)GetValue(HeaderForegroundProperty); }
			set { SetValue(HeaderForegroundProperty, value); }
		}

		// Using a DependencyProperty as the backing store for HeaderForeground.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty HeaderForegroundProperty =
			DependencyProperty.Register("HeaderForeground", typeof(Brush), typeof(CharmControl), new PropertyMetadata(null));

		public object HeaderContent
		{
			get { return (object)GetValue(HeaderContentProperty); }
			set { SetValue(HeaderContentProperty, value); }
		}

		// Using a DependencyProperty as the backing store for HeaderContent.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty HeaderContentProperty =
			DependencyProperty.Register("HeaderContent", typeof(object), typeof(CharmControl), new PropertyMetadata(null));

		public Brush ContentBackground
		{
			get { return (Brush)GetValue(ContentBackgroundProperty); }
			set { SetValue(ContentBackgroundProperty, value); }
		}

		// Using a DependencyProperty as the backing store for ContentBackground.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty ContentBackgroundProperty =
			DependencyProperty.Register("ContentBackground", typeof(Brush), typeof(CharmControl), new PropertyMetadata(null));

		public Brush ContentForeground
		{
			get { return (Brush)GetValue(ContentForegroundProperty); }
			set { SetValue(ContentForegroundProperty, value); }
		}

		// Using a DependencyProperty as the backing store for ContentForeground.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty ContentForegroundProperty =
			DependencyProperty.Register("ContentForeground", typeof(Brush), typeof(CharmControl), new PropertyMetadata(null));

		public Style BackButtonStyle
		{
			get { return (Style)GetValue(BackButtonStyleProperty); }
			set { SetValue(BackButtonStyleProperty, value); }
		}

		// Using a DependencyProperty as the backing store for BackButtonStyle.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty BackButtonStyleProperty =
			DependencyProperty.Register("BackButtonStyle", typeof(Style), typeof(CharmControl), new PropertyMetadata(null));

		public ICommand BackCommand
		{
			get { return (ICommand)GetValue(BackCommandProperty); }
			set { SetValue(BackCommandProperty, value); }
		}

		// Using a DependencyProperty as the backing store for BackCommand.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty BackCommandProperty =
			DependencyProperty.Register("BackCommand", typeof(ICommand), typeof(CharmControl), new PropertyMetadata(null));
	}
}